package com.quanyan.vote.task.tracker;

import com.github.ltsopensource.core.domain.Action;
import com.github.ltsopensource.tasktracker.Result;
import com.github.ltsopensource.tasktracker.logger.BizLogger;
import com.github.ltsopensource.tasktracker.runner.JobContext;
import com.github.ltsopensource.tasktracker.runner.JobRunner;
import com.github.ltsopensource.tasktracker.runner.LtsLoggerFactory;
import com.quanyan.api.APIResponse;
import com.quanyan.vote.service.TbVoteExpertAdminService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by xian-guo on 2016/6/29.
 */
@Component("jobRunnerA")
public class JobRunnerA implements JobRunner{

    private static final Logger LOGGER = LoggerFactory.getLogger(JobRunnerA.class);

    @Autowired
    private TbVoteExpertAdminService tbVoteExpertAdminService;

    /**
     * 跟新达人票数
     * @param jobContext
     * @return
     * @throws Throwable
     */
    @Override
    public Result run(JobContext jobContext) throws Throwable {
        try {
            APIResponse<Boolean> apiResponse=tbVoteExpertAdminService.countDayIncrement();
            LOGGER.info("----每天跟新达人票数是否成功----->>>>>"+apiResponse.getData());
        } catch (Exception e) {
            LOGGER.info("Run job failed!", e);
            return new Result(Action.EXECUTE_LATER, "--跟新达人每日票数失败--->"+e.getMessage());
        }
        return new Result(Action.EXECUTE_SUCCESS, "--跟新达人票数成功----");
    }
}
